#!/usr/bin/env python
# coding: utf-8

# In[43]:


import plotly as py
import cufflinks as cf
import pandas as pd
import numpy as np


# In[75]:


df=pd.read_csv("fsnd_zb_sample_energy.tsv",encoding="utf8",sep="\t",keep_default_na=False,na_values='na-rep')
df.head()


# In[45]:


df.地区名.unique()


# In[60]:


dfc=df.set_index("指标名").loc["电力消费量"].set_index("地区名").loc[['北京市','天津市','上海市','重庆市'],["2009","2010","2011","2012","2013"]]
dfc


# In[61]:


dfc.iplot(kind="bar")


# In[63]:


dfm=df.query("地区名 in ['北京市','上海市','广东省']").set_index(["指标名","地区名"])[["2009"]]
dfm


# In[54]:


dfm.unstack()


# In[64]:


dfm.unstack().iplot(kind="bar")


# In[55]:


dfm.unstack(0)


# In[76]:


dfm.unstack(0).iplot(kind="bar")


# In[77]:


dfm.stack()


# In[78]:


dfm.stack().iplot(kind='bar')


# In[ ]:





# In[ ]:





# In[ ]:




